<template>
  <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body :close-on-click-modal="false"
             v-dialogDrag>
    <div class="app-container">
      <el-table border v-loading="loading" :data="dataList"  ref="table"
                :max-height="tableMaxHeight">
        <el-table-column label="产品编码" align="center" prop="code"/>
        <el-table-column label="产品名称" align="center" prop="goodsName"/>
        <el-table-column label="产品型号" align="center" prop="goodModel"/>
        <el-table-column label="产品明细" align="center" prop="goodsBrand"/>
        <el-table-column label="产品单位" align="center" prop="unit"/>
        <el-table-column label="是否质检" align="center" prop="isZhijian"/>
        <el-table-column label="质检日期" align="center" prop="zhijianDate"/>
        <el-table-column label="质检人" align="center" prop="zhijianName"/>

        <!--<el-table-column label="单价" align="center" prop="goodsBuyPrice"/>
        <el-table-column label="采购数量" align="center" prop="shengyu"/>
        <el-table-column label="重量" align="center" prop="dun"/>
        <el-table-column label="含税总价" align="center" prop="goodsBuyTotal"/>-->
        <el-table-column label="备注" align="center" prop="remark"/>
        <el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="140">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="showChild(scope.row)">采购明细</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize" @pagination="getList"/>
    </div>
    <goods-salebuyLists ref="showsalebuyForm" @ok="getList"></goods-salebuyLists>
  </el-dialog>
</template>

<script>
  import { getAction} from '@/api/manage'
  import GoodsSalebuyLists from "@/views/develop/lvBuy/module/GoodsSalebuyLists";

  export default {
    name: "ZhijianformList",
    components: {
      GoodsSalebuyLists
    },
    data() {
      return {
        title: "记录",
        open: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        rows: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 销售信息管理表格数据
        dataList: [],
        // 查询参数
        queryParams: {
          cgallid:null,
          pageNum: 1,
          pageSize: 20,
          mainId: null,
          name: null,
          brand: null,
          unit: null,
          costPrice: null,
          count: null,
          cost: null,
          validityTerm: null,
          buyId: null,
          buyName: null,
          buyDate: null,
          buyType: null,
          reimburse: null,
          supplierId: null,
          supplierName: null,
          dateRange: "",
          daohuoId: null,
          params: {},
        },
        url: {
          list: '/goodsSalebuyall/goodsSalebuyall/list',
        },
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
      // this.intDictsForPrj();
      window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
      window.removeEventListener('resize', this.getTableHeight);
    },
    methods: {
      showChild(row){
        this.$refs.showsalebuyForm.showsalebuyList(row);
      },
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      showdaohuo(row){
        this.queryParams.daohuoId=row.id;
        this.open=true;
        this.getList();
      },
      /** 查询销售信息管理列表 */
      getList() {
        this.loading = true;
        getAction(this.url.list, this.queryParams).then(response => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
    }
  };
</script>
